package com.zlj.accountant.services;

import java.util.UUID;

import com.zlj.accountant.core.AbstractService;
import com.zlj.accountant.core.HandlerManager;
import com.zlj.accountant.core.ann.Publish;
import com.zlj.accountant.db.dao.DBHelper;
import com.zlj.accountant.db.entity.TAccountFund;
import com.zlj.accountant.publish.task.CreateAccountFundTask;
import com.zlj.accountant.publish.view.FAccountFund;

public class AccountFundPublicService extends AbstractService {

	public AccountFundPublicService(DBHelper dbHelper) {
		super(dbHelper);
	}
	
	
	
//	@Publish
	public void create(CreateAccountFundTask task){
		TAccountFund a = new TAccountFund();
		a.setFundCode(task.fundCode);
		a.setIncome(task.income);
		a.setOutgo(task.outgo);
		a.setName(task.name);
		a.setPerson(task.person);
		a.setShare(task.share);
		setSystemInfo(a);
//		getService().handle(a);
	}	
	
	
	@Publish
	protected final class GetFAccountFundByIdProvider extends OneKeyResultProvider<FAccountFund, UUID>{

		@Override
        public FAccountFund provide(HandlerManager handler, UUID id)
                throws Exception
        {
			TAccountFund t = handler.find(TAccountFund.class,id);
			FAccountFund r = new FAccountFund();
			r.balance = t.getIncome() - t.getOutgo();
			r.fundCode = t.getFundCode();
			r.fundName = t.getName();
			r.id = id;
			r.income = t.getIncome();
			r.outgo = t.getOutgo();
			r.share = t.getShare();
			return r;
        }
		
	}

}
